package jinyilw.swing.rlaf.utils;

import jinyilw.swing.ColorTools;

import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Window;

/**
 * @author Jinyi
 */
public class RPopupFactory extends PopupFactory
{

	public RPopupFactory()
	{
	}

	@Override
	public Popup getPopup(Component owner, Component contents, int x, int y)
			throws IllegalArgumentException
	{
		Popup popup = super.getPopup(owner, contents, x, y);
		Window window = SwingUtilities.getWindowAncestor(contents);
		if (window != null
				&& window.getBackground() != ColorTools.transparentColor)
		{
			window.setBackground(ColorTools.transparentColor);
		}
		return popup;
	}

}
